class Test {
    constructor() {
        this.init();
    }
    init() {
        let container1 = document.querySelector('.container1');
        let container2 = document.querySelector('.container2');
        if (this.isDeviceOrientationEventSupported()) {
            window.addEventListener('deviceorientation', (event) => {
                container1.innerHTML = `orientation:<br>alpha:${event.alpha}<br> beta:${event.beta}<br> gamma:${event.gamma}`
            });
        } else {
            alert('deviceorientation event not supported');
        }
        if (this.isDeviceMotionEventSupported()) {
            window.addEventListener('devicemotion', (event) => {
                container2.innerHTML = `======================<br>motion:<br>acceleration:<br>x:${event.acceleration.x}<br>y:${event.acceleration.y}<br>z:${event.acceleration.z}<br> accelerationIncludingGravity:<br>x:${event.accelerationIncludingGravity.x}<br>y:${event.accelerationIncludingGravity.y}<br>z:${event.accelerationIncludingGravity.z}<br> interval:${event.interval}`
            });
        } else {
            alert('devicemotion event not supported');
        }
        return this;

    }
    getEvent() {
        return this.event
    }
    isDeviceOrientationEventSupported() {
        if (window.DeviceOrientationEvent) {
            return true;
        }
        return false;
    }
    isDeviceMotionEventSupported() {
        if (window.DeviceMotionEvent) {
            return true;
        }
        return false;
    }
}
module.exports = Test;
